#!/usr/bin/python
# -*- coding:utf-8 -*-
# @time: 2021/6/7 2:12 下午

from mongoengine import Document, fields
from models.meta import QuerySetNoCache


class AuditLog(Document):
    """
    操作日志及登录日志
    """

    meta = {
        'collection': 'audit_log',
        'queryset_class': QuerySetNoCache,
        'ordering': ['-time']
    }
    domain = fields.StringField(blank=True)  # 域名
    property_name = fields.StringField(blank=True)  # 业务系统名
    operator = fields.StringField()  # 操作人
    group = fields.ListField()  # 分组名
    time = fields.IntField()  # 操作操作时间 timestamp
    ip = fields.StringField()  # 操作IP
    source = fields.StringField()  # 操作源
    module = fields.StringField()  # 操作模块
    action = fields.StringField()  # 动作
    type = fields.StringField()  # 操作类型+登录类型
    desc = fields.DictField()  # 详细描述
    status = fields.StringField(blank=True)  # 登录状态
